<!--
author:        leishanfeng <1628316216@qq.com>
date:          2023-07-19 15:25:13
component:     index
Copyright © YourCompanyName All rights reserved
-->
<template>
  <el-dialog
    :visible.sync="outerVisible"
    width="580px"
    height="526px"
    append-to-body
    center
    :before-close="close"
  >
    <template slot="title">
      <div
        style="
          font-size: 18px;
          font-family: MicrosoftYaHei;
          color: rgba(255, 255, 255, 0.9);
          font-weight: normal;
        "
      >
        选择人员
      </div>
    </template>
    <div class="addBox">
      <el-input
        placeholder="输入关键词搜索人员"
        prefix-icon="el-icon-search"
        v-model="input"
        @input="validateCounts($event)"
      >
      </el-input>
      <tx-button-add name="新增成员" @click="add" style="margin-left: 16px" />
    </div>
    <div class="content">
      <div v-if="result.length != 0" class="newrenyuan">
        <div
          class="renyuanlist"
          :class="{ active: currentIndex == index }"
          v-for="(item, index) in result"
          :key="index"
          @click="selectItem(item, index)"
        >
          <img
            :src="require('@/assets/TeamAdministrator/icon_folder_shut.png')"
            class="renyuanImg"
          />
          <div>
            <div class="renyuanName">
              {{ item.displayName
              }}{{ item.phoneNum ? `（${item.phoneNum}）` : '' }}
            </div>
            <div class="renyuanxiangqing">{{ item.depLevel }}</div>
          </div>
        </div>
      </div>
      <div v-else class="wujieguo">
        <div class="wujieguoImg"></div>
        <div class="wujieguoTip">未找到人员，可点击顶部添加成员新增</div>
      </div>
    </div>
    <div class="btnBox">
      <el-button
        @click="newdialogVisible(1)"
        style="
          background: #1d5a8f;
          border-radius: 4px;
          border: 1px solid #7cadd8;
          font-size: 16px;
          font-family: MicrosoftYaHei;
          color: rgba(255, 255, 255, 0.9);
        "
        >取消</el-button
      >
      <el-button
        @click="newdialogVisible(2)"
        style="
          border: 1px solid #38c2c6;
          background: #38c2c6;
          border-radius: 4px;
          font-size: 16px;
          font-family: MicrosoftYaHei;
          color: rgba(255, 255, 255, 0.9);
        "
        >确 定</el-button
      >
    </div>
  </el-dialog>
</template>

<script>
import { idaasFindUsersByPhone } from '@/api/resourceManagement/index.js'
export default {
  props: ['isOuterVisible'],
  data() {
    return {
      renyuanxinxi: '',
      outerVisible: false,
      input: '',
      result: [],
      currentIndex: -1
    }
  },
  watch: {
    isOuterVisible: {
      handler(newValue, oldValue) {
        console.log(oldValue)
        this.outerVisible = newValue
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    // 确定或者取消
    newdialogVisible(e) {
      console.log(e)
      if (e == 1) {
        this.outerVisible = false
      } else if (e == 2) {
        this.$emit('getHeadName', this.renyuanxinxi)
        this.outerVisible = false
      }
    },
    close() {
        console.log('clsor')
      this.outerVisible = false
      this.$emit("close","")
     
    },
    selectItem(item, index) {
      console.log(item)
      this.renyuanxinxi = item
      this.currentIndex = index
    },
    validateCounts(e) {
      console.log(e)
      idaasFindUsersByPhone({ name: e }).then(res => {
        console.log(res.data)
        this.result = res.data
      })
    },
    add() {
      this.outerVisible = false
      this.$emit('addMembers', true)
    }
  }
}
</script>
<style lang="scss" scoped>
.el-dialog__wrapper {
  ::v-deep .el-dialog {
    .el-dialog__header {
      .el-dialog__headerbtn {
        font-size: 14px;
      }
      .el-icon-close:before {
        color: #4af6fc;
      }
    }
  }
}
::v-deep .el-input__inner {
  height: 32px !important;
}
::v-deep .el-input--suffix .el-input__inner {
  width: 100% !important;
}

//调整右侧icon的布局中
::v-deep .el-input__icon {
  line-height: 28px !important;
}
.addBox {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}
.btnBox {
  width: 100%;
  height: 81px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.content {
  height: 318px;
  overflow-y: hidden;
}
.wujieguo {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  .wujieguoImg {
    width: 280px;
    height: 180px;
    background: url('~@/assets/TeamAdministrator/wujieguo.png') no-repeat;
  }
  .wujieguoTip {
    font-size: 16px;
    font-family: MicrosoftYaHei;
    color: #7cadd8;
    height: 21px;
    line-height: 21px;
  }
}
.newrenyuan {
  height: 318px;
  overflow-y: auto;
  .active {
    background: rgba(74, 246, 252, 0.1);
    box-shadow: inset 0px 0px 10px 0px #4af6fc;
  }
  .renyuanlist {
    width: 530px;
    height: 64px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    line-height: 64px;
    cursor: pointer;
    .renyuanImg {
      width: 30px;
      height: 30px;
      margin: 0 10px;
      //   background-size: 100% 100%;
      //   background: url('~@/assets/TeamAdministrator/icon_folder_shut.png') no-repeat;
    }
    .renyuanName {
      width: 460px;
      height: 21px;
      font-size: 16px;
      font-family: MicrosoftYaHei;
      color: rgba(255, 255, 255, 0.9);
      line-height: 21px;
      margin-bottom: 4px;
    }
    .renyuanxiangqing {
      width: 480px;
      height: 19px;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      color: #cbe7ff;
      line-height: 19px;
      white-space: normal;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
    }
  }
}
::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
  height: 1px;
  background: #0d3e67;
}
::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  //   border-radius: 10px;

  background: #1d5a8f;
}
::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  box-shadow: inset 0 0 5px #0d3e67;
  border-radius: 10px;
  background: #1d5a8f;
}

::-webkit-scrollbar-track-piece {
  width: 15px;
  background: #0d3e67;
}
</style>
